<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String basePath = request.getScheme() + "://" +
            request.getServerName() + ":" + request.getServerPort() +
            request.getContextPath() + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>查看房间</title>
    <base href="<%=basePath%>" />
    <script type="text/javascript" src="js/jquery-3.4.1.js"></script>
    <script type="text/javascript">
        $(function(){
            //在当前页面dom对象加载后，执行loadStudentData（）
            loadStudentData();
            $("#btnLoader").click(function(){
                loadStudentData();

            })
        })

        function loadStudentData(){
            $.ajax({
                url:"hlm/queryHome.do",
                type:"get",
                dataType:"json",
                success:function(data){
                    //清除旧的数据
                    $("#info").html("");
                    //增加新的数据
                    $.each(data,function(i,n){
                        $("#info").append("<tr>")
                            .append("<td>"+n.kefangbianhao+"</td>")
                            .append("<td>"+n.kefangleixing+"</td>")
                            .append("<td>"+n.jiage+"</td>")
                            .append("<td>"+n.shiyongzhuangtai+"</td>")
                            .append("</tr>")

                    })
                }
            })
        }
    </script>
</head>
<body>
<p>查看房间</p>
<div align="center">
    <table>
        <thead>
        <tr>
            <td>客房编号</td>
            <td>客房类型</td>
            <td>价格</td>
            <td>使用状态</td>
        </tr>
        </thead>
        <tbody id="info">

        </tbody>
    </table>
    <input type="button" id="btnLoader" value="查询数据">
</div>
</body>
</html>
